;==========================
;      TRUSHE MOSAIC
;BY rasmer\INNERCORE GROUP
;23.03.2007-26.03.2007
;COMPO EDITION - 18.12.2007
;==========================
        ORG #7000
STARTF: LD HL,#5800
        LD DE,#5801
        LD BC,#300
        LD (HL),%00111000
        LDIR
        LD H,#80
        LD D,H
        INC B
        LD (HL),%00111000
        LDIR
MAINLOOP:
        EI
        HALT
SCREEN_ADRESS:
        LD DE,#50FF              ;FIND
        INC E                    ;NEXT 
        LD A,E                   ;ADRESS
        LD (SCREEN_ADRESS+1),A   ;ON
        JR NZ,NOT_NEW_TRIPLE     ;THE
        LD A,D                   ;SCREEN
        ADD #08                  ;
        CP #58                   ;
        JR NZ,NOT_END_OF_SCREEN  ;
        LD A,#40                 ;
NOT_END_OF_SCREEN:               ;
        LD D,A                   ;
        LD (SCREEN_ADRESS+2),A   ;
;=======================
NOT_NEW_TRIPLE:
        LD A,R
        LD L,A
        AND 3
        LD H,A
        XOR (HL)
        AND %00001000
        LD C,A ;B=0
        LD HL,MOSAIK
        ADD HL,BC
        LD B,8
DRAWINGMOSAIC:
        LD A,(HL)
        LD (DE),A
        INC HL
        INC D
        DJNZ DRAWINGMOSAIC
MAYBESCROLL:
        LD A,0
        CPL
        LD (MAYBESCROLL+1),A
        OR A
        JR Z,MAINLOOP
;=========================
;OCHISTKA
;=========================
CLEARASIL:
        LD HL,0
        PUSH HL
        POP DE
        INC E
        INC B
        LD (HL),%00111000
        LDIR
;=========================
;VIVOD NA EKRAN
;=========================
SINUSKA LD A,0
        INC A
        AND %00001111
        LD (SINUSKA+1),A
        LD HL,SINUS
        ADD A,L
        LD L,A
        LD L,(HL)
        LD H,B ;B=0
        ADD HL,HL
        ADD HL,HL
        ADD HL,HL
        ADD HL,HL
        ADD HL,HL
        LD DE,#5800
        ADD HL,DE
        EX DE,HL
        LD (CLEARASIL+1),DE
        LD H,#80
        PUSH HL
        PUSH HL
        INC B
        LDIR
;========================
;SCROLL
;========================
SKROLL: LD A,01
        DEC A
        JR Z,NEWSYMB
SKRL003 LD (SKROLL+1),A
        POP DE
        POP HL
        INC L
        LD C,#C0
        LDIR
        LD HL,CURRENTSYMBOL
        LD E,#1F
        LD B,6
SKRL001 LD A,%00111000
        RL (HL)
        JR NC,NULLOK
        XOR %01000000
NULLOK: LD (DE),A
        LD A,#20
        ADD A,E
        LD E,A
        INC HL
        DJNZ SKRL001
        JP MAINLOOP
NEWSYMB LD HL,TEXT
        BIT 7,(HL)
        JR Z,NOTNEWTEKST
        LD HL,TEXT
NOTNEWTEKST
        LD A,(HL)
        INC HL
NOTCLR  LD (NEWSYMB+1),HL
        LD H,B
        LD L,A
        ADD HL,HL
        ADD HL,HL
        ADD HL,HL
        LD DE,#3C01
        ADD HL,DE
        LD DE,CURRENTSYMBOL
        LD C,7
        LD A,C
        OUT (#FE),A
        LDIR
        JR SKRL003
        JP MAINLOOP
TEXT    DEFB "TRUSHE MOSAIC! ",#FF
;======================================
MOSAIK  DEFB %00010000
        DEFB %00010000
        DEFB %00100000
        DEFB %11000000
        DEFB %00000011
        DEFB %00000100
        DEFB %00001000
        DEFB %00001000
        DEFB %00001000
        DEFB %00001000
        DEFB %00000100
        DEFB %00000011
        DEFB %11000000
        DEFB %00100000
        DEFB %00010000
        DEFB %00010000
;======================================
SINUS   DEFB #03,#05,#07,#09
        DEFB #0B,#0D,#0F,#10
        DEFB #10,#10,#0F,#0D
        DEFB #0B,#09,#07,#05
;======================================
CURRENTSYMBOL:
ENDEC   DISPLAY ENDEC-STARTF
        SAVEBIN "TRUSHETRO.C",#7000,#100
        SAVESNA "trushetro.sna",STARTF